<template>
	<view>
		<uni-search-bar placeholder="查询物流单号BSKD0000001" @confirm="shou"></uni-search-bar>
		<u-swiper :height="250" :list="lun" :effect3d="true" :interval="3000" @click="click"></u-swiper>
		<uni-group title="物流公司">
			<view class="item-container">
				<view class="thumb-box" v-for="(item1, index1) in reactive" :key="index1" @click="toinde(item1.id)">
					<image class="item-menu-image" :src="base+item1.imgUrl" mode=""></image>
					<view class="item-menu-name">{{item1.name}}</view>
				</view>
			</view>
		</uni-group>
		<uni-group title="其他物流公司">
			<uni-list>
				<uni-list-item v-for="(item,index) in reactive2" :thumb="base+item.imgUrl" :title="item.name"></uni-list-item>
			</uni-list>
		</uni-group>
	</view>
</template>

<script>
	import api from 'commer/apiURL.js'
	export default {
		data() {
			return {
				base: api.baseurl,
				lun: [],
				reactive:[],
				reactive2:[],
			}
		},
		onBackPress() {
			uni.switchTab({
				url: '../allserver'
			})
			return true
		},
		onLoad() {
			this.getlun()
			this.getquna()
		},
		methods: {
			shou(e){
				var str = e.value.replace(/\s*/g,'')
				this.$get(this.base+'/prod-api/api/logistics-inquiry/logistics_info/'+str).then((res)=>{
					if(res.code == 200){
						uni.setStorage({
							key: 'dc',
							data: str,
							success: (res) => {
								uni.navigateTo({
									url:'xian2?order='+str
								})
							}
						})
					}else{
						uni.showToast({
							title:res.msg,
							icon:'none'
						})
					}
				})
			},
			toinde(id){
				uni.navigateTo({
					url:'xian?id='+id
				})
			},
			getlun() {
				this.$get(this.base + '/prod-api/api/logistics-inquiry/ad-banner/list').then((res) => {
					res.data.forEach((item) => {
						this.lun.push({
							image: this.base + item.imgUrl
						})
					})
				})
			},
			getquna(){
				this.$get(this.base+'/prod-api/api/logistics-inquiry/logistics_company/list').then((res)=>{		
					this.reactive = res.data.slice(0,12)
					this.reactive2 = res.data.slice(12,res.data.length)
				})
			},
		}
	}
</script>

<style>
	.item-container {
		display: flex;
		flex-wrap: wrap;
	}

	.thumb-box {
		width: 25%;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		margin-top: 20rpx;
	}

	.item-menu-image {
		width: 50rpx;
		height: 50rpx;
	}
</style>
